<template>
  <div class="top">
    <div class="left">
      <span class="lbtn" @click="goHome">首页</span>
    </div>
    <div class="mid">
      <div class="mid-txt">
        智慧旅游可视化大数据平台
      </div>
    </div>
    <div class="right">
      <span class="right-btn">统计报告</span>
      <span class="right-txt">{{time}}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from 'vue'
import moment from 'moment'
import { useRouter } from 'vue-router'
const router = useRouter()

// 存储当前时间
const time = ref(moment().format('YYYY年MM月DD日 hh:mm:ss'))
let timer = ref()
// 首页
const goHome = () => {
  router.push('/home')
}

onMounted( ()=> {
  timer.value = setInterval(()=>{
    time.value = moment().format('YYYY年MM月DD日 hh:mm:ss')
  },1000)
})

onBeforeUnmount(()=>{
  clearInterval(timer.value)
})

</script>

<style lang="scss" scoped>
  .top {
    width: 100%;
    height: 40px;
    display: flex;
    .left, .right {
      flex: 1.5;
    }
    .left {
      background: url(../../images/dataScreen-header-left-bg.png) no-repeat;
      background-size: cover;
      display: flex;
      justify-content: flex-end;
      .lbtn {
        width: 135px;
        line-height: 40px;
        text-align: center;
        color: #29fcff;
        height: 40px;
        background: url(../../images/dataScreen-header-btn-bg-l.png) no-repeat;
        background-size: 100% 100%;
        cursor: pointer;
      }
    }
    .right {
      background: url(../../images/dataScreen-header-left-bg.png) no-repeat;
      background-size: cover;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .right-btn {
        width: 135px;
        line-height: 40px;
        text-align: center;
        color: #29fcff;
        height: 40px;
        background: url(../../images/dataScreen-header-btn-bg-r.png) no-repeat;
        background-size: 100% 100%;
        cursor: pointer;
      }
      .right-txt {
        color: #29fcff;
        margin-right: 10px;
        font-size: 20px;
      }
    } 
    .mid {
      flex: 3;
      .mid-txt {
        width: 100%;
        height: 74px;
        line-height: 74px;
        color: #29fcff;
        font-size: 30px;
        text-align: center;
        background: url(../../images/dataScreen-header-center-bg.png) no-repeat;
        background-size: 100% 100%;
      }
    }
  }
</style>
